package com.openlogic.common.core.web.nami;

import org.noear.nami.Filter;
import org.noear.nami.Invocation;
import org.noear.nami.Result;

import com.openlogic.common.core.constants.HttpConstant;
import com.openlogic.common.core.constants.basic.TenantConstants;
import com.openlogic.common.core.utils.ContextUtil;

/**
 * @ClassName: INamiClientFilter
 * @Description: Nami过滤器
 * @author weiyongpeng
 * @date 2025年1月30日 上午8:27:57
 */
public interface INamiClientFilter extends Filter {

	/**
	 * 过滤器
	 * @param inv
	 * @return
	 * @throws Throwable
	 */
	default Result doFilter(Invocation inv) throws Throwable {
		inv.headers.putAll(ContextUtil.getHeaders(HttpConstant.TOKEN_NAME,TenantConstants.TENANT_ID));
//		HeadersUtils.setTenantId(inv.headers.get(TenantConstants.TENANT_ID));
//		SecurityContextHolder.setEnterpriseId(inv.headers.get(TenantConstants.TENANT_ID));
		return inv.invoke();
	}

}
